package com.huashi.dealer.modular.business.order.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.huashi.dealer.core.config.JacksonConfigure;
import com.huashi.dealer.core.handler.HtmlContentTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * Store端订单详情响应VO
 * 对应PHP项目的订单详情显示数据
 *
 * @author 谭陈强
 * @since 2025-08-15
 */
@Data
@Schema(description = "订单详情响应数据")
public class StoreOrderDetailVo {

    @Schema(description = "订单ID", example = "1001")
    private Long orderId;

    @Schema(description = "订单号", example = "202508150001")
    private String orderNo;

    @Schema(description = "用户ID", example = "1001")
    private Integer userId;

    @Schema(description = "订单总金额", example = "99.00")
    @JsonSerialize(using = JacksonConfigure.BigDecimalSerializer.class)
    private BigDecimal totalPrice;

    @Schema(description = "实付金额", example = "99.00")
    @JsonSerialize(using = JacksonConfigure.BigDecimalSerializer.class)
    private BigDecimal payPrice;

    @Schema(description = "运费", example = "10.00")
    @JsonSerialize(using = JacksonConfigure.BigDecimalSerializer.class)
    private BigDecimal expressPrice;

    @Schema(description = "优惠金额", example = "10.00")
    @JsonSerialize(using = JacksonConfigure.BigDecimalSerializer.class)
    private BigDecimal discountPrice;

    @Schema(description = "创建时间", example = "2025-08-15 10:30:00")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @Schema(description = "支付时间", example = "2025-08-15 10:35:00")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime payTime;

    @Schema(description = "发货时间", example = "2025-08-15 14:00:00")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime deliveryTime;

    @Schema(description = "收货时间", example = "2025-08-17 10:00:00")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime receiptTime;

    @Schema(description = "订单备注", example = "请尽快发货")
    private String remark;

    @Schema(description = "商品列表")
    private List<OrderGoodsDetailVo> goods;

    @Schema(description = "收货地址信息")
    private OrderAddressVo address;

    @Schema(description = "买家信息")
    private OrderUserDetailVo user;

    @Schema(description = "支付方式")
    private PayTypeVo payType;

    @Schema(description = "配送方式")
    private DeliveryTypeVo deliveryType;

    @Schema(description = "付款状态")
    private OrderStatusVo payStatus;

    @Schema(description = "审核状态")
    private OrderStatusVo auditStatus;

    @Schema(description = "发货状态")
    private OrderStatusVo deliveryStatus;

    @Schema(description = "收货状态")
    private OrderStatusVo receiptStatus;

    @Schema(description = "订单状态")
    private OrderStatusVo orderStatus;

    @Schema(description = "驳回原因", example = "商品库存不足")
    private String rejectReason;

    @Schema(description = "物流信息")
    private List<OrderExpressVo> orderExpress;

    @Schema(description = "自提门店信息")
    private ExtractShopVo extractShop;

    /**
     * 订单商品详细信息
     */
    @Data
    @Schema(description = "订单商品详细信息")
    public static class OrderGoodsDetailVo {

        @Schema(description = "商品ID", example = "1001")
        private Long goodsId;

        @Schema(description = "商品名称", example = "iPhone 15 Pro")
        private String goodsName;

        @Schema(description = "商品规格", example = "256GB 深空黑色")
        private String goodsAttr;

        @Schema(description = "商品价格", example = "99.00")
        @JsonSerialize(using = JacksonConfigure.BigDecimalSerializer.class)
        private BigDecimal goodsPrice;

        @Schema(description = "优惠活动价格", example = "89.00")
        @JsonSerialize(using = JacksonConfigure.BigDecimalSerializer.class)
        private BigDecimal discountActivePrice;

        @Schema(description = "购买数量", example = "1")
        private Integer totalNum;

        @Schema(description = "商品类型：10-普通商品，20-赠品", example = "10")
        private Integer isType;

        @Schema(description = "商品图片")
        private GoodsImageVo image;

        @Schema(description = "已发货数量", example = "1")
        private Integer totalCheckNum;

        @Schema(description = "商品重量(Kg)")
        private Double goodsWeight;

        @Schema(description = "商品总价(数量×单价)")
        private BigDecimal totalPrice;

        @Schema(description = "商品总库存")
        private Integer stockNum;
    }

    /**
     * 商品图片信息
     */
    @Data
    @Schema(description = "商品图片信息")
    public static class GoodsImageVo {

        @Schema(description = "图片路径", example = "https://example.com/image.jpg")
        private List<String> filePath;
    }

    /**
     * 收货地址信息
     */
    @Data
    @Schema(description = "收货地址信息")
    public static class OrderAddressVo {

        @Schema(description = "收货人姓名", example = "张三")
        private String name;

        @Schema(description = "收货人电话", example = "13800138000")
        private String phone;

        @Schema(description = "详细地址", example = "北京市朝阳区xxx街道xxx小区")
        private String detail;

        @Schema(description = "省份", example = "北京市")
        private String province;

        @Schema(description = "城市", example = "北京市")
        private String city;

        @Schema(description = "区县", example = "朝阳区")
        private String region;
    }

    /**
     * 订单用户详细信息
     */
    @Data
    @Schema(description = "订单用户详细信息")
    public static class OrderUserDetailVo {

        @Schema(description = "用户ID", example = "1001")
        private Long userId;

        @Schema(description = "用户昵称", example = "张三")
        private String nickName;

        @Schema(description = "用户头像", example = "https://example.com/avatar.jpg")
        private String avatarUrl;

        @Schema(description = "用户手机号", example = "13800138000")
        private String mobile;

        @Schema(description = "用户真实姓名", example = "张三")
        private String realName;
    }

    /**
     * 支付方式信息
     */
    @Data
    @Schema(description = "支付方式信息")
    public static class PayTypeVo {

        @Schema(description = "支付方式值", example = "10")
        private Integer value;

        @Schema(description = "支付方式名称", example = "微信支付")
        private String text;
    }

    /**
     * 配送方式信息
     */
    @Data
    @Schema(description = "配送方式信息")
    public static class DeliveryTypeVo {

        @Schema(description = "配送方式值", example = "10")
        private Integer value;

        @Schema(description = "配送方式名称", example = "快递配送")
        private String text;
    }

    /**
     * 订单状态信息
     */
    @Data
    @Schema(description = "订单状态信息")
    public static class OrderStatusVo {

        @Schema(description = "状态值", example = "20")
        private Integer value;

        @Schema(description = "状态名称", example = "已付款")
        private String text;
    }

    /**
     * 物流信息
     */
    @Data
    @Schema(description = "物流信息")
    public static class OrderExpressVo {

        @Schema(description = "物流ID", example = "1001")
        private Integer orderExpressId;

        @Schema(description = "物流公司", example = "顺丰快递")
        private String expressCompany;

        @Schema(description = "物流单号", example = "SF1234567890")
        private String expressNo;

        @Schema(description = "商品数量", example = "1")
        private String goodsNum;

        @Schema(description = "物流图片")
        private List<String> images;

        @Schema(description = "物流图片文件名")
        private List<String> imagesValue;

        @Schema(description = "发货时间", example = "2025-08-15 14:00:00")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime deliveryTime;
    }

    /**
     * 自提门店信息
     */
    @Data
    @Schema(description = "自提门店信息")
    public static class ExtractShopVo {

        @Schema(description = "门店ID", example = "1001")
        private Long shopId;

        @Schema(description = "门店名称", example = "北京朝阳店")
        private String shopName;

        @Schema(description = "门店地址", example = "北京市朝阳区xxx街道")
        private String address;

        @Schema(description = "门店电话", example = "010-12345678")
        private String phone;

        @Schema(description = "营业时间", example = "09:00-22:00")
        private String businessHours;
    }
}
